package repositories;

import java.util.Collection;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import domain.Bid;

@Repository
public interface BidRepository extends JpaRepository<Bid,Integer> {
	
	// List the bids of an auction
	@Query("select b from Bid b where b.auction.id = ?1")
	Collection<Bid> findBidsByAuctionId(int auctionId);
	
	// Select the highest bid
	@Query("select b from Bid b where b.money = (select max(bAux.money) from Bid bAux)")
	Collection<Bid> findHighestBid();

}
